Skip to content

Conversation

kaushikrw
Copy link
Collaborator

@kaushikrw kaushikrw commented Aug 14, 2025

Related to issue: #kotlin/6416

Description:

This PR introduces the framework for mocking network responses for any tests in the toolkit.

Summary of changes:

  • Added dependency on the mockingjay library which is used for mocking network data.
  • Introduced a new gradle plugin GrantTestPermission which will grant the required permissions to the test app. This is used for granting elevated permissions such as MANAGE_EXTERNAL_STORAGE which is necessary for reading the mocked response files stored in the root of the storage on the test device.
  • Enabled mocking for the FeatureFormTests.
  • Fixed the failing group element tests.

Note : This is dependent on the companion sdk PR in the linked issue.

Pre-merge Checklist

@kaushikrw kaushikrw changed the base branch from main to feature-branches/forms August 14, 2025 21:36
@kaushikrw kaushikrw self-assigned this Aug 18, 2025
@kaushikrw kaushikrw marked this pull request as ready for review August 19, 2025 00:29
@kaushikrw kaushikrw marked this pull request as draft August 19, 2025 19:25
@kaushikrw kaushikrw marked this pull request as ready for review October 14, 2025 18:36
Copy link
Collaborator

@gunt0001 gunt0001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaushikrw - looks good. I suggest to merge this straight into v.next though. Once on v.next, @rom14514 can continue the work to consolidate the test utils in a shared library etc. At some point this would also be merged into v.next and if you are still working on this feature branch at that point, you can rebase.

Would that work?

@gunt0001 gunt0001 requested a review from hud10837 October 15, 2025 12:35
@kaushikrw kaushikrw changed the base branch from feature-branches/forms to v.next October 15, 2025 16:42
@kaushikrw
Copy link
Collaborator Author

kaushikrw commented Oct 15, 2025

@kaushikrw - looks good. I suggest to merge this straight into v.next though.

Would that work?

I may have branched off from the feature branch.. so this might also include changes from the feature branch. Is that okay? Alternatively, I can create another PR to merge the feature-branches/forms into v.next right after this is first merged into feature-branches/forms.

@kaushikrw kaushikrw changed the base branch from v.next to feature-branches/forms October 15, 2025 16:51
Copy link
Collaborator

@hud10837 hud10837 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approving so this could move forward but I do have questions to guide the follow-up work

Comment on lines 43 to -48

// Grant camera permission for barcode scanning
@get:Rule
val runtimePermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(Manifest.permission.CAMERA)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am understanding this correctly, then the GrantTestPermissions plugin doesn't actually need to grant the camera permission before running the tests, because the test can request it. I have some questions about this though:

  1. Could we grant the storage permissions using GrantPermissionRule? If so, could we add that as a BeforeAfterAction once we have that available to the toolkit (soon)? I investigated this and it's not possible
  2. If we can't do the above, could we keep the Camera permission granted at this level? This would be helpful because it would mean we could share the grant permissions task from the SDK plugin without modifications
  3. When we use GrantPermissionRule, we don't need to worry about the manifest? I'm guessing that is the case because I don't see it in the docs and you are just now adding the permissions to the manifest

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can't do the above, could we keep the Camera permission granted at this level? This would be helpful because it would mean we could share the grant permissions task from the SDK plugin without modifications.

Yeah, the camera permission can stay within the test. I just moved it out because the having all the permissions granted by the plugin made sense.

When we use GrantPermissionRule, we don't need to worry about the manifest? I'm guessing that is the case because I don't see it in the docs and you are just now adding the permissions to the manifest

I believe so according to the doc. But the manage storage permission definitely need the manifest.

@gunt0001
Copy link
Collaborator

I may have branched off from the feature branch.. so this might also include changes from the feature branch. Is that okay? Alternatively, I can create another PR to merge the feature-branches/forms into v.next right after this is first merged into feature-branches/forms.

Ok, in that case, I think the options are:

  1. Go ahead and merge this PR into your feature branch. We will make changes independently on v.next to introduce the shared test util lib and the shared gradle plugin for data syncing. In this case you will likely need to resolve conflicts once you merge your feature branch into v.next.
  2. Do what you suggest above - Alternatively, I can create another PR to merge the feature-branches/forms into v.next right after this is first merged into feature-branches/forms.

Whatever works best for you...

@kaushikrw
Copy link
Collaborator Author

kaushikrw commented Oct 16, 2025

Thanks @gunt0001 and @hud10837. I will merge this and follow up with a PR into v.next.

@kaushikrw kaushikrw merged commit 58bd6f3 into feature-branches/forms Oct 16, 2025
@kaushikrw kaushikrw deleted the kaushik/forms/network-request-mocking branch October 16, 2025 16:28
sorenoid pushed a commit that referenced this pull request Oct 17, 2025
* bump hilt version

* remove validation errors filtering (#762)

* updated validation behavior (#787)

* bump androidXCamera and ksp

* `Forms` : Fix how Attachment states are created (#801)

* update how attachment states are created

* remove onExpressionsEvaluated

* Update gradle.properties

* `FeatureForm` : initial support for UtilityAssociations (#776)

* `Forms` : New Attachments UI (#825)

* fix compilation error due to missing parameter

* `Forms`: Microapp updates (#834)

* enable and fix edge-to-edge

* use safedrawing

* fix select feature dialog height

* add loading callout when identifying layers

* `FeatureForm` : UN Associations enhancements (#783)

* `FeatureForm` : Add "Delete" Associations UI (#855)

* `FeatureForm` : Add UtilityAssociationsFormElement UI tests (#863)

* `FeatureForm` : Update Association Display UI (#889)

* `FeatureForm` : Provide navigation blocking  (#909)

* `FeatureForm` : Re-introduce ValidationErrorVisibility (#910)

* `FeatureForm` : Update attachment size limits (#921)

* `FeatureForm`: Update UN Association Display Spec (#934)

* update login view model to use list of oauth user configurations (#932)

* `FeatureForm`: Micro-app - Update how thumbnails are rendered (#959)

* bump sdk version to 300.0

* `FeatureForm` : Remove deprecated api (#965)

* `FeatureForm`: Microapp add folder browsing (#964)

* `FeatureForm` : Micro-app datastore updates (#968)

* `FeatureForm` : Add delete UNA implementation  (#978)

* add navigate back when last association is deleted (#983)

* add test case 12.6 (#982)

* `FeatureForm` : Honor UNA is editable and minor refactor (#986)

* `FeatureForm` : UNA Add Implementation (Feature 1) (#988)

* Add filter/search functionality (#991)

* refactor navigation to support nested destinations

* add paging, symbology display for features

* change feature list title

* add association creation

* add asset type selection

* add final screens

* optimize imports and extract strings

* update association creation logic

* extract strings

* updated ignored api classes

* Add filter/search functionality

* revert logic to determine query result size from paging params

* add ignore for  "com.arcgismaps.toolkit.featureforms.internal.utils.ComposableSingletons\$SearchBarKt"

* remove paging

* CR : Puneet

* rename routes

* rename more routes

* move filtering logic to the composable from viewModel

* update SearchBar UI

* abstract filter logic to viewmodel

* update doc

* address code review comments

* update padding

* don't clear sources filter in selectSource

---------

Co-authored-by: Kaushik Meesala <[email protected]>

* `FeatureForm` : UI updates for the UNA add impl (#993)

* `FeatureForm` : Updates to AddAssociationFromSourceViewModel.kt (#996)

* Introduce network mocking to the toolkit (#969)

---------

Co-authored-by: Erick Lopez Solis <[email protected]>
Co-authored-by: Puneet Prakash <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants